home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
xmsif.exe
/
XMSTEST2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-08
|
27KB
|
670 lines
/***************************************************************************
* xmstest2.c *
* MODULE: XMSIF *
* OS: DOS *
* VERSION: 1.0 *
* DATE: 12/08/91 *
* *
* Copyright (c) 1991 James W. Birdsall. All Rights Reserved. *
* *
* Requires xmsif.h, testutil.h, and xmstest.h to compile. *
* Compiles under Borland C++ 2.0, Turbo C 2.0, or MSC 6.00A. *
* *
* Regression test and example for XMSIF. See XMSTEST.C for more detail. *
* *
***************************************************************************/
/*
** system includes <>
*/
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <string.h>
/*
** custom includes ""
*/
#include "xmsif.h"
#include "xmstest.h"
#include "testutil.h"
/*
** local #defines
*/
/*
** misc: copyright strings, version macros, etc.
*/
/*
** typedefs
*/
/*
** global variables
*/
extern int testno;
extern char *gblmsg;
/*
** static globals
*/
/*
** function prototypes
*/
static void do_ncopy2_tests(void);
/*
** functions
*/
/***************************************************************************
* FUNCTION: DO_COPY_TESTS *
* *
* DESCRIPTION: *
* *
* Dispatcher function for copy test functions. *
* *
* ENTRY: *
* *
* None. *
* *
* EXIT: *
* *
* Void. *
* *
* CONSTRAINTS/SIDE EFFECTS: *
* *
***************************************************************************/
void do_copy_tests(void)
{
do_ncopy1_tests();
do_ncopy2_tests();
do_icopy_tests();
return;
} /* end of do_copy_tests() */
/***************************************************************************
* FUNCTION: DO_NCOPY2_TESTS (STATIC) *
* *
* DESCRIPTION: *
* *
* Tests normal copy functions (_XMMcopy() and macros). *
* *
* ENTRY: *
* *
* None. *
* *
* EXIT: *
* *
* Void. *
* *
* CONSTRAINTS/SIDE EFFECTS: *
* *
***************************************************************************/
static void do_ncopy2_tests(void)
{
int handle;
unsigned char far *realbuf;
unsigned char far *guard1, far *guard2, far *guard3;
unsigned char far *testbuf;
unsigned char far *testbuf2;
int status;
unsigned long start, stop, total;
unsigned char huge *temp;
unsigned long loop;
/* first, allocate some XMS to test with */
handle = XMMalloc(MINFREE);
weirdcodechk("XMMalloc", 0, (void far *) NULL, 0, 0);
/* next, allocate a conventional memory buffer */
realbuf = (unsigned char far *) LMALLOC((MINFREE/1024L) + 3);
if (realbuf == (unsigned char far *) NULL)
{
printf("Can't allocate conventional buffer. Aborting.\n");
XMMfree(handle);
exit(3);
}
/* set up guard zones, etc. */
guard1 = realbuf;
FMEMSET(guard1, GUARDVAL, 1024);
testbuf = (unsigned char far *) normptr(guard1 + 1024);
guard2 = (unsigned char far *) normptr(testbuf + HALFLEN);
FMEMSET(guard2, GUARDVAL, 1024);
testbuf2 = (unsigned char far *) normptr(guard2 + 1024);
guard3 = (unsigned char far *) normptr(testbuf2 + HALFLEN);
FMEMSET(guard3, GUARDVAL, 1024);
/* set up patterns */
farincwordfill(testbuf, HALFLEN, 0);
FMEMSET(testbuf2, 0, HALFLEN);
status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
/*
** Now, try various copies to EMB, then copy HALFLEN of EMB back to
** testbuf2 for checking.
*/
gblmsg = " COPY TESTS CONVENTIONAL-EMB";
/* try an even-length copy from offset 0 to offset 0 */
TESTHEADER();
printf("XMMcopyto(): even-length copy from offset 0 to offset 0.\n");
printf("Should succeed.\n");
status = XMMcopyto(50, testbuf, handle, 0L);
TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
SRCWORDCHECK(testbuf, HALFLEN);
GUARDCHECK(handle);
CPYWORDCHECK(testbuf2, 50);
ZEROCHECK((testbuf2 + 50), (HALFLEN - 50));
TESTTAILER();
/* restore destination pattern */
FMEMSET(testbuf2, 0, HALFLEN);
status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
/* try an even-length copy from offset 0 to arbitrary offset */
TESTHEADER();
printf("XMMcopyto(): even-length copy from offset 0 to arbitrary offset.\n");
printf("Should succeed.\n");
status = XMMcopyto(50, testbuf, handle, 477L);
TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
status = XMMcopyfrom(HALFLEN, handle, 0L, testbuf2);
TRIPLECHECK("XMMcopyfrom()", status, 0, (void far *) realbuf, handle, 0);
GUARDCHECK(handle);
SRCWORDCHECK(testbuf, HALFLEN);
ZEROCHECK(testbuf2, 477);
MEMCMP(testbuf, (testbuf2 + 477), 50);
ZEROCHECK((testbuf2 + 477 + 50), ((HALFLEN - 477) - 50));
TESTTAILER();
/* restore destination pattern */
FMEMSET(testbuf2, 0, HALFLEN);
status = XMMcopyto(HALFLEN, testbuf2, handle, 0L);
TRIPLECHECK("XMMcopyto()", status, 0, (void far *) realbuf, handle, 0);
/* try an even-length copy from offset 0 to just before the end */
TESTHEADER();
printf("XMMcopyto(): even-length copy from offset 0 to just before end.\n");
printf("S